package com.witdata.controller.docker;

import com.witdata.common.domain.Result;
import com.witdata.common.domain.Status;
import com.witdata.common.domain.dto.InstanceDto;
import com.witdata.rabbit.service.InstanceService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/docker/instance")
@RequiredArgsConstructor
public class InstanceController {
    private final InstanceService instanceService;

    @GetMapping("/list")
    public Result<List<InstanceDto>> getDockerList() {
        List<InstanceDto> instanceList = instanceService.getInstanceList();
        return Result.ok(Status.SUCCESS, instanceList);
    }

    @PostMapping("/edit")
    public Result<String> editInstance(@RequestBody InstanceDto instanceDto) {
        instanceService.updateInstance(instanceDto);
        return Result.ok(Status.INSTANCEEDITSUCCESS);
    }

    @PostMapping("/remove")
    public Result<String> removeInstance(@RequestBody InstanceDto instanceDto) {
        instanceService.deleteInstance(instanceDto.getId());
        return Result.ok(Status.REMOVESUCCESS);
    }

}
